home *** CD-ROM | disk | FTP | other *** search
- /* dup.c --- p 492 */
- #include <stdio.h>
- #include <io.h>
- char message[] = "Testing dup. This should appear on stdout\n";
- main()
- {
- int newhandle;
- /* By default, stdout has handle 1.
- * creat another handle for stdout*/
- if((newhandle = dup(1)) == -1)
- perror("dup on handle 1 failed!");
- else
- {
- printf("New handle for stdout is %d\n", newhandle);
- write(newhandle, message, sizeof(message));
- }
- }